#include "Precompile.h"
#include "EngineManager.h"
#include "ModelLoader.h"
#include "SkySphere.h"
#include "EditorState.h"

EngineManager::EngineManager(){
}

void EngineManager::renderFunc(Graphics::RenderContext* context){
	InputSystemPtr input = m_engine->getInputSystemPtr();
	input->synchronizeInput();
	
	m_stateManager->update();
}

bool EngineManager::initialize(EngineInterfacePtr engine){
	m_engine = engine;

	m_stateManager = StateManagerPtr(new StateManager);
	m_renderConnection = m_engine->getRenderSystemPtr()->RenderingEvent.registerHandler(this,&EngineManager::renderFunc);

	// Add editor state
	m_stateManager->addState(IStatePtr(new EditorState(m_engine)));
	return true;
}